package com.info33.platform.business.app.controller;

import com.info33.platform.business.app.entity.AppRole;
import com.info33.platform.business.app.service.AppRoleService;
import com.info33.platform.business.app.vo.AppRoleVO;
import com.info33.platform.common.mvc.controller.BaseController;
import com.info33.platform.common.mvc.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author admin
 */
@RestController
@RequestMapping("/AppRole")
@Api(tags = "app - 角色")
public class AppRoleController extends BaseController<AppRoleService, AppRole> {

    private final AppRoleService appRoleService;

    @Autowired
    public AppRoleController(AppRoleService appRoleService) {
        super(appRoleService);
        this.appRoleService = appRoleService;
    }

    @GetMapping(value = "/app/roles")
    @ApiOperation(value = "app - 我所拥有的角色")
    public Result<List<AppRoleVO>> appRoles() {
        return Result.ok(appRoleService.appRoles(getCurrentUser()));
    }

    @DeleteMapping(value = "/pc/remove/{id}")
    @ApiOperation(value = "pc - 删除角色")
    public Result<Object> pcRemove(
            @PathVariable(value = "id") Long id) {
        return appRoleService.pcRemove(id);
    }

}